package com.sen.pro.switches.front.action;

import java.io.IOException;

import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.sen.common.struts.BaseAction;
import com.sen.pro.switches.core.cfg.ENV;
import com.sen.pro.switches.core.common.Constants;
import com.sen.pro.switches.core.util.ActionUtils;
import com.sen.pro.switches.core.util.SiteFileUtil;

/**
 * 客制方案
 * 
 * @author tian qingsen
 */
@Scope("prototype")
@Controller("solutionAction")
@Namespace("/")
public class SolutionAction extends BaseAction {

	private static final long serialVersionUID = -6137594499765644421L;
	private static Logger LOG = Logger.getLogger(SolutionAction.class);

	@Action(value = "solution", results = { @Result(name = SUCCESS, location = "/WEB-INF/view/solution.jsp") })
	public String index() {
		LOG.info("客制方案");
		ActionUtils.initSiteImg(request);
		initHtmlContent();
		return SUCCESS;
	}
	
	private void initHtmlContent() {
		try {
			String htmlFile = ServletActionContext.getServletContext().getRealPath("/") + ENV.HTML_DIR + "/" + Constants.SOLUTION_HTML_NAME;
			request.setAttribute("htmlDesc", SiteFileUtil.getSiteHtmlFileToStr(htmlFile));
		} catch (IOException e) {
			LOG.error("读取客制方案信息出错", e);
		}
	}
}
